/*
 * User.h
 *
 */

#ifndef USER_H_
#define USER_H_

#include "../../persistence/hash/HashRecord.h"

#define FIRSTNAME_LENGTH 100
#define LASTNAME_LENGTH 100
#define PASSWORD_LENGTH 32
#define PROVINCE_LENGTH 100

class User : public HashRecord {
private:
	BigInt dni;
	String firstName;
	String lastName;
	String password;
	StringVector emails;
	String province;
	char type;

public:
	User();
	virtual ~User();

	User(BigInt dni, const String& firstName, const String& lastName, const String& password, const String& province, char type);
	User(const User& copy);
	User& operator=(const User& other);

	BigInt getDni() const { return dni; }
	const String& getFirstName() const { return firstName; }
	const String& getLastName() const { return lastName; }
	const String& getPassword() const { return password; }
	const String& getProvince() const { return province; }
	StringVector& getEmails() { return emails; }
	char getType() const { return type; }

	void setDni(BigInt value) { dni = value; }
	void setFirstName(const String& value) { firstName = value; }
	void setLastName(const String& value) { lastName = value; }
	void setPassword(const String& value) { password = value; }
	void setProvince(const String& value) { province = value; }
	void setType(char value) { type = value; }

	bool isValid() const;

	BigInt getHashcode() const;
	BigInt size() const;
	void serialize(ISerializer& serializer) const;
	void unserialize(IUnserializer& unserializer);

protected:
	bool isTypeValid(char type) const;
};

#endif /* USER_H_ */
